package org.korifey.ffbdd.chess;
import static org.korifey.ffbdd.chess.Position.BOARDSIZE;

public class Coord {
	private int h;
	private int v;
	
	public String toString() {
		return Character.toString((char)('a' + h)) + (v+1);
	}
	
	public int v() { return v;}
	public int h() { return h;}
	
	public boolean equals(Object o) {
		if (o == null || !(o instanceof Coord)) return false;
		Coord c = (Coord)o;
		return v == c.v() && h == c.h();
	}
	
	public int hashCode() {
		return h * 8 + v;
	}
	
	static Coord[][] coords;
	static {
		coords = new Coord[BOARDSIZE][BOARDSIZE];
		for (int i=0; i<BOARDSIZE; i++) 
			for (int j=0; j<BOARDSIZE; j++)
				coords[i][j] = new Coord(i, j);
	}
	
	protected Coord(int h, int v) {
		super();
		this.h = h;
		this.v = v;
	}
	
	public static Coord get(int h, int v) {
		return coords[h][v];
	}
	
	
}
